using GameLogic;
using System;
using System.Collections.Generic;
using System.Linq;
using TEngine;
using UnityEditor;
using UnityEngine;

[System.Serializable]
public class ItemDetails
{
    public int itemID;  //道具ID
    public string itemName; //道具名称
    public ItemType itemType;   //道具类型
    public Sprite itemIcon; //道具图片
    public Sprite itemOnWorldSprite;    //场景生成图片
    public string itemDescription;  //道具描述
    public int itemUseRadius;   //道具使用范围
    public bool canPickedup;    //是否能被拾取
    public bool canDropped; //是否可以被扔
    public bool canCarried; //是否可以举着
    public int itemPrice;   //道具价格
    [Range(0, 1)]
    public float sellPercentage;    //售卖折扣百分比
}

[System.Serializable]
public class InventoryItem
{
    public int itemID;
    public int itemAmount;
    public int itemPos;
}

[System.Serializable]
public class PlayerInfo
{
    public string _username;    //用户姓名
    public Dictionary<int,InventoryItem> itemsSlot;//玩家物品槽
    public Dictionary<int, InventoryItem> itemsBag;//玩家背包槽
}

[System.Serializable]
public class AnimatorType
{
    public PartType partType;
    public PartName partName;
    public AnimatorOverrideController overrideController;
}

[System.Serializable]
public class SerializableVector3
{
    public float x, y, z;

    public SerializableVector3(Vector3 pos)
    {
        this.x = pos.x;
        this.y = pos.y;
        this.z = pos.z;
    }

    public Vector3 ToVector3()
    {
        return new Vector3(x, y, z);
    }

    public Vector2Int ToVector2Int()
    {
        return new Vector2Int((int)x, (int)y);
    }
}

[System.Serializable]
public class SceneItem
{
    public int itemID;
    public SerializableVector3 position;
}

[System.Serializable]
public class SceneFurniture
{
    public int itemID;
    public SerializableVector3 position;
    public int boxIndex;
}

[System.Serializable]
public class TileProperty
{
    public Vector2Int tileCoordinate;
    public GridType gridType;
    public bool boolTypeValue;
}


[System.Serializable]
public class TileDetails
{
    public int girdX, gridY;    //土地的坐标
    public bool canDig;     //土地是否被挖矿
    public bool canDropItem;    //土地是否可以扔东西
    public bool canPlaceFurniture;  //土地是否可以放置家具
    public bool isNPCObstacle;  //土地是否可以让NPC走
    public bool alreadySown;    
    public float sinceDuged = -1;
    public float Wetness = 10;  //土地湿度
    public float Fertility = 10;    //土地肥度
    public int seedItemID = -1; //土地上的种子ID
    public float growthTimes = -1;  //种植时间
    public int growthDays = -1; //种了几天了
    public int daysSinceLastHarvest = -1;   //自从上次收割多久了
    // 当前温度（假设有外部系统提供）
    public float Temperature { get; set; } = 20f;   //土地温度

    // 当前种植的种子（如果有）
    public SeedDetails PlantedSeed { get; set; }

    public bool isVisible = false;
    public DateTime lastWetnessUpdate = DateTime.MinValue;
    public DateTime lastFertilityUpdate = DateTime.MinValue;
}

[System.Serializable]
public class SeedDetails
{
    public int SeedID { get; set; }
    public string Name { get; set; }

    public int currentGrowthTime;   //种子长了多久了(s)

    public int currentDayTime;  //种子长了多久了(d)

    public int currentGrowthStages; //当前种子生长到哪个阶段了

    public string currentCropPrefab; //当前种子对应阶段的预制体叫什么

    public float DeathTimer= 0f;  //当前种子的濒死倒计时

    // 基础种子掉落概率
    public float BaseSeedDropRate = 0.2f; //掉落种子的概率是多少

    public bool IsCropDead  = false; //种子是否死亡

    public bool IsRipe = false; //作物是否成熟

    public SeedAttribute actuallySeedAttribute;
}

public class SeedAttribute
{
    public int SeedID { get; set; }
    public int OptimalTempMin { get; set; } //最适温度区间最小值
    public int OptimalTempMax { get; set; } //最适温度区间最大值
    public int ExtremeTempMin { get; set; } //极限温度区间最小值
    public int ExtremeTempMax { get; set; } //极限温度区间最大值
    public int OptimalMoistureMin { get; set; } //最适湿度区间最小值
    public int OptimalMoistureMax { get; set; } //最适湿度区间最大值
    public int ExtremeMoistureMin { get; set; } //极限湿度最小值
    public int ExtremeMoistureMax { get; set; } //极限湿度最大值
    public int OptimalFertilityMin { get; set; } //最适肥度区间最小值
    public int OptimalFertilityMax { get; set; } //最适肥度区间最大值
    public int ExtremeFertilityMin { get; set; } //极限肥度最小值
    public int ExtremeFertilityMax { get; set; } //极限肥度最大值
    public string DeathTimeThreshold { get; set; } //超出极限几天会死亡
    public string BaseYield { get; set; } //基础产量
    public string BaseSeedDropRate { get; set; } //种子掉落概率

}

[System.Serializable]
public class NPCPosition
{
    public Transform npc;
    public string startScene;
    public Vector3 position;
}

//场景路径
[System.Serializable]
public class SceneRoute
{
    public string fromSceneName;
    public string gotoSceneName;
    public List<ScenePath> scenePathList;
}

[System.Serializable]
public class ScenePath
{
    public string sceneName;
    public Vector2Int fromGridCell;
    public Vector2Int gotoGridCell;
}